<title>查看销售业绩</title>
<style>
  .main{
            width:50%;
            height:400px;
            border: 2px solid orange;
            margin:60px auto;
            line-height:50px;
            padding-left: 30px;
        }
    
    </style>
<?php
header("content-type:text/html; charset=utf-8");

session_start();
$name=$_SESSION['user-name'];

$selectdate=$_POST['select'];
$selecttype=$_POST['selecttype'];
$year=substr($selectdate,0,4);//截取字符串年份
$month=substr($selectdate,0,6);//截取字符串到月份结束
$serverLink=@mysql_connect("localhost","root","root") or die("连接服务器失败！程序中断");
mysql_query("set names 'utf-8'");
$dbLink= @mysql_select_db("supermarket") or die("打开supermarket数据库失败！程序中断");
if($selecttype=='年销售'){

    $selectsql="select * from saleslist where vendorname='$name' and salesdate like '$year%'";
    
}else if($selecttype=='月销售'){
$selectsql="select * from saleslist where vendorname='$name' and salesdate like '$month%'";
}else{
$selectsql="select *from saleslist where vendorname='$name' and salesdate='$selectdate'";
}

$outselect=mysql_query($selectsql);
$count="0";
echo "<div class=main>";
echo"<h3>销售明细</h3>";
echo "销售产品如下：";
while($db=mysql_fetch_array($outselect)){
$count+=$db['salescount'];
echo $db['productname']." ".$db['salescount']."件"." ";
}
echo "<br/>";
echo "总销售产品：" .$count."件"."<br/>";

echo "<a href=subper.php><button>返回主页</button></a>";
echo "</div>";
mysql_close($serverLink);
?>